package codetop;

public class lc466_chongfugeshu {
    public static void main(String[] args) {
        System.out.println(getMaxRepetitions("acb", 4, "ab", 2));
    }
    public static int getMaxRepetitions(String s1, int n1, String s2, int n2) {
        int i = 0;
        int p = 0;
        for (; i < n1; i++) {
            if(isValid(s1, s2, 0) == s2.length()){
                p = 1;
                break;
            }
        }
        if(p == 0)
            return 0;
        return n1 / ((i + 1) * n2);
    }
    public static int isValid(String s1, String s2, int k){
        int j = k;
        for (int i = 0; i < s1.length() && j < s2.length(); ) {
            if(s1.charAt(i) == s2.charAt(j)){
                i++;
                j++;
            }
            else{
                i++;
            }
        }
        return j;
    }
}
